package com.you.concurrent.synchronize;

/**
 * 测试synchronized是重入锁
 */
public class ReSynchronizedDemo {

    public synchronized void demo1() { //获得对象锁
        System.out.println("----demo1----");
        demo2();
    }

    public void demo2() {
        synchronized (this) { //使用同一把锁，增加重入次数
            System.out.println("----demo2----");
        }
    }

    public static void main(String[] args) {
        ReSynchronizedDemo reSynchronizedDemo = new ReSynchronizedDemo();
        reSynchronizedDemo.demo1();
    }
}
